package com.shen.langchain4j.controller;

import cn.hutool.core.date.DateUtil;
import com.shen.langchain4j.service.ChatPersistenceAssistant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/chatPersistence")
public class ChatPersistenceController {
    @Autowired
    private ChatPersistenceAssistant chatPersistenceAssistant;

    @GetMapping(value = "chatOne")
    public String getChatOne() {
        chatPersistenceAssistant.chat(1L, "我的名字叫小李");
        chatPersistenceAssistant.chat(2L, "我的名字叫小刘");

        String answer1 = chatPersistenceAssistant.chat(1L, "我的名字叫什么");
        String answer2 = chatPersistenceAssistant.chat(2L, "我的名字叫什么");

        return "test success: " + DateUtil.now() + "answer1: " + answer1 + "answer2: " + answer2;
    }
}
